package hc.bre.rest.cmn

import org.springframework.beans.BeansException
import org.springframework.context.ApplicationContext
import org.springframework.context.ApplicationContextAware
import org.springframework.context.EnvironmentAware
import org.springframework.core.env.Environment
import org.springframework.stereotype.Component

@Component
class SpringContext implements ApplicationContextAware,EnvironmentAware{
	static ApplicationContext applicationContext;
	static Environment environment;

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		this.applicationContext = applicationContext
	}

	public static <T> T getBean(Class<T> cls) {
		return applicationContext.getBean(cls);
	}

	@Override
	public void setEnvironment(Environment environment) {
		this.environment = environment;
	}

	public static String getProp(String key){
		return environment.getProperty(key);
	}
}
